home *** CD-ROM | disk | FTP | other *** search
- #define __SRC__
- #include <stdio.h>
- #include "lib.h"
- /* prints() is like printf(), except that it can only handle %s and %c. It
- * cannot print any of the numeric types such as %d, %o, etc. It has the
- * advantage of not requiring the runtime code for converting binary numbers
- * to ASCII, which saves 1K bytes in the object program. Since many of the
- * small utilities do not need numeric printing, they all use prints.
- */
- #define GETARG(typ) *((typ *)valp)++
-
- void prints(s, arglist)
- _CONST register char *s;
- char *arglist;
- {
- register w;
- int k, *valp;
- char *p, *p1, c;
-
- valp = (int *) &arglist;
-
- while (*s != '\0') {
- if (*s != '%') {
- putchar(*s++);
- continue;
- }
-
- w = 0;
- s++;
- while (*s >= '0' && *s <= '9') {
- w = 10 * w + (*s - '0');
- s++;
- }
-
-
- switch(*s) {
- case 'c': k = GETARG(int); putchar(k); s++; continue;
-
- case 's':
- p = (GETARG(char *));
-
- p1 = p;
- while(c = *p++) putchar(c); s++;
- if ( (k = w - ((int)(p-p1)-1)) > 0) while (k--) putchar(' ');
- continue;
- default: putchar('%'); putchar(*s++); continue;
- }
-
- }
- }
-
-
-